import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


public class NumberFrequencyAppear {
	
	public static void main(String[] args) {

	    int iArr[] = {2, 1, 9, 6, 4, 8, 55, 77, 41, 0, 4, 9, 9, 77, 90, 76, 54};
	    Map<Integer, Integer> numberFrequencyMap = new HashMap<Integer, Integer>();

	    System.out.println("Original array");
	    for (int number : iArr) {
	      System.out.print(number+" ");
	    }
	    
	    for (int number : iArr){
	    	int count = numberFrequencyMap.containsKey(number) ? numberFrequencyMap.get(number) : 0;
	    	numberFrequencyMap.put(number, count + 1);
	    }

	    System.out.println("\nResult After processed");
	    for (Integer number : numberFrequencyMap.keySet()) {
			System.out.println(number.toString() + " appears "+ numberFrequencyMap.get(number));
		}
	}
}
/* Result
Original array
2 1 9 6 4 8 55 77 41 0 4 9 9 77 90 76 54 
Result After processed
0 appears 1
1 appears 1
2 appears 1
55 appears 1
4 appears 2
54 appears 1
6 appears 1
76 appears 1
8 appears 1
77 appears 2
9 appears 3
41 appears 1
90 appears 1
*/
